package com.stone.serverless.core.classloader.config;

import cn.hutool.core.util.ObjectUtil;
import com.stone.serverless.sdk.constant.EnvironmentConstant;
import com.stone.serverless.sdk.domain.ServiceInfo;
import com.stone.serverless.sdk.enums.RuntimeTypeEnum;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @Description: TODO
 * @Author: MECHREVO
 * @Date: 2022/1/17 16:52
 * @Version: 1.0.0
 */
@Getter
@Setter
public class ComponentBizConfig {

    /**
     * 组件名称 唯一
     */
    private String componentName;

    /**
     * 组件链接地址
     */
    private String url;

    /**
     * 版本
     */
    private String version = EnvironmentConstant.DEFAULT_VERSION;

    /**
     * 组件扫描路径
     */
    private String basePackage;

    /**
     * 描述
     */
    private String description;


    /**
     * 需要的外部服务集合
     */
    private List<ServiceInfo> services;

    /**
     * 运行类型
     */
    private RuntimeTypeEnum runtimeType;

    public ComponentBizConfig(String url, String componentName) {
        this.url = url;
        this.componentName = componentName;
    }

    public void uninstall() {
        this.componentName = null;
        this.version = null;
        this.url = null;
        this.basePackage = null;
        if(ObjectUtil.isNotNull(services)){
            this.services.clear();
        }
        this.services = null;
        this.description = null;

    }
}
